import pyautogui
from time import sleep


def get_mouse_position():
    try:
        while True:
            x, y = pyautogui.position()
            print(x, y)
            sleep(0.5)
    except KeyboardInterrupt:
        print("结束...")


def mouse_move(start:dict, end:dict, duration=5):
    """
    控制鼠标从start移动至end
    :param start: 传值示例{"x":0, "y":0}
    :param end:
    :param duration: 移动时长
    :return:
    """
    pyautogui.moveTo(start.get("x"), start.get("y"), duration=0.1)
    pyautogui.moveTo(end.get("x"), end.get("y"), duration=duration)


if __name__ == '__main__':
    # start = {"x":-1964, "y":606}
    # end = {"x":-76, "y":606}
    # mouse_move(start, end, 10)
    get_mouse_position()
